package com.lb.jwitter.action;


 import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
 import java.util.Collection;
import java.util.Date;
import java.util.List;

 import org.springframework.beans.factory.annotation.Autowired;
import com.lb.jwitter.util.ApplicationContextProvider; 
import com.lb.jwitter.util.ThoiKhoaBieuPhongNgay;
import com.lb.jwitter.util.ThoiKhoaBieuPhongNgayMonHoc;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; 
import org.springframework.test.context.ContextConfiguration;
 import com.opensymphony.xwork2.Action; 
 import java.util.Map; 
 import com.opensymphony.xwork2.ActionContext; 
import com.lb.jwitter.service.ConditionReport; 
import com.lb.jwitter.service.TblQLDTTXAGiaoVien;
import com.lb.jwitter.service.TblQLDTTXAGiaoVienService;
import com.lb.jwitter.service.TblQLDTTXAHocKyTrongNam;
import com.lb.jwitter.service.TblQLDTTXAHocKyTrongNamService;
 import com.lb.jwitter.service.TblQuyenChiTietService;import com.lb.jwitter.service.TblTaiKhoan;import com.lb.jwitter.service.TblQLDTTXAThoiKhoaBieuChinhThuc;


 /** 
 * @author QUOCVIET  
 * 
 */ 


@ContextConfiguration(locations="classpath:beans.xml") 
public class XemDiemSoHocVienFormAction{
    private int pageSize; 
    public int getPageSize() {
       return pageSize;
 }

    public void setPageSize(int pageSize) { this.pageSize = pageSize; }

    private int page; 
    public int getPage() { return page; }

    public void setPage(int page) { this.page = page; }

    private int pages; 
    public int getPages() { return pages; }

    public void setPages(int pages) { this.pages = pages; }

    private String dataString; 
    public String getDataString() { return dataString; }
    
    private int view;


    private TblQLDTTXAHocKyTrongNamService tblQLDTTXAHocKyTrongNamService; 

    private TblQLDTTXAHocKyTrongNam tblQLDTTXAHocKyTrongNam;
    
    private List<TblQLDTTXAHocKyTrongNam> tblQLDTTXAHocKyTrongNams;
    
    private Long hocKyId;



  private TblTaiKhoan taiKhoanDangNhap; 
 public TblTaiKhoan getTaiKhoanDangNhap() { 
     return taiKhoanDangNhap; 
 } 
 public void setTaiKhoanDangNhap(TblTaiKhoan taiKhoanDangNhap) { 
     this.taiKhoanDangNhap = taiKhoanDangNhap; 
 } 
 private TblQuyenChiTietService tblQuyenChiTietService;
	 @Autowired // Injected by Spring 
     ApplicationContextProvider contextProvider;
	 
 public String execute() throws Exception 
{ 
 try{ 	
     Map session = ActionContext.getContext().getSession();
     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
     if( taiKhoanDangNhap == null) return "noprivilege";
    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 
    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_QLDTTXA_ThoiKhoaBieuChinhThuc", "xem")){ 
        return "noprivilege"; 
    }
    
        tblQLDTTXAHocKyTrongNamService = (TblQLDTTXAHocKyTrongNamService) context.getBean("tbl_QLDTTXA_HocKyTrongNamClient"); 

        List<ConditionReport> cons = new ArrayList<ConditionReport>(); 
        //get hocky
//        Date today = new Date();
//        if(hocKyId != null && !hocKyId.equals(new Long(0))){
//        	ConditionReport con = new ConditionReport(); 
//            con.setCol("id");
//            con.setValue1(hocKyId);
//            con.setOperator("eq");
//            cons.add(con);	
//        } else{
//        	DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); 
//
//        	ConditionReport con = new ConditionReport(); 
//            con.setCol("thoiGianBatDau");
//            con.setValue1(df.format(today));
//            con.setOperator("le");
//            con.setType("date");
//            cons.add(con);	
//            
//            ConditionReport con2 = new ConditionReport(); 
//            con2.setCol("thoiGianKetThuc");
//            con2.setValue1(df.format(today));
//            con2.setOperator("ge");
//            con2.setType("date");
//            cons.add(con2);	
//        }
//        tblQLDTTXAHocKyTrongNams = tblQLDTTXAHocKyTrongNamService.findtblQLDTTXAHocKyTrongNamByCondition(cons, 0, 0);
//
//        if(tblQLDTTXAHocKyTrongNams != null && tblQLDTTXAHocKyTrongNams.size() ==1){ 
//            tblQLDTTXAHocKyTrongNam = tblQLDTTXAHocKyTrongNams.get(0);
//        }

        cons.clear();
        {
        	ConditionReport con = new ConditionReport(); 
            con.setCol("thoiGianBatDau");
            con.setValue1("desc");
            con.setOperator("order");
            cons.add(con);
        }
       
        tblQLDTTXAHocKyTrongNams = tblQLDTTXAHocKyTrongNamService.findtblQLDTTXAHocKyTrongNamByCondition(cons, 20, 1);
        
        return Action.SUCCESS; 
      } 
      catch(Exception e){ 
      System.out.println("Loi Form Xem Diem So Action"); 
     e.printStackTrace(); 
    return Action.ERROR; 
 } 
 }

public TblQLDTTXAHocKyTrongNam getTblQLDTTXAHocKyTrongNam() {
	return tblQLDTTXAHocKyTrongNam;
}

public void setTblQLDTTXAHocKyTrongNam(
		TblQLDTTXAHocKyTrongNam tblQLDTTXAHocKyTrongNam) {
	this.tblQLDTTXAHocKyTrongNam = tblQLDTTXAHocKyTrongNam;
}

public Long getHocKyId() {
	return hocKyId;
}

public void setHocKyId(Long hocKyId) {
	this.hocKyId = hocKyId;
}


public int getView() {
	return view;
}

public void setView(int view) {
	this.view = view;
}

public List<TblQLDTTXAHocKyTrongNam> getTblQLDTTXAHocKyTrongNams() {
	return tblQLDTTXAHocKyTrongNams;
}

public void setTblQLDTTXAHocKyTrongNams(
		List<TblQLDTTXAHocKyTrongNam> tblQLDTTXAHocKyTrongNams) {
	this.tblQLDTTXAHocKyTrongNams = tblQLDTTXAHocKyTrongNams;
} 
 } 
 
